package com.lhlk.reflection;


/**
 *获取class类方法有那些
 */
public class test1 {
    public static void main(String[] args) throws ClassNotFoundException {
        student person=new student();

        person.aa();
        //通过类.class
        Class<student> sClass = student.class;
        System.out.println(sClass.hashCode());

        //通过实例对象获取
        Class aClass = person.getClass();
        System.out.println(aClass.hashCode());

        //通过Class.forName()
        Class<?> forName = Class.forName("com.lhlk.reflection.student");
        System.out.println(forName.hashCode());

        //获取student的父类
        Class superclass = aClass.getSuperclass();
        System.out.println(superclass);
        System.out.println(person.getClass().getSuperclass());


    }
}
class Person{
    private String name;
    public Person(){

    }
    public static void a(String name){
        System.out.println("这个人是"+name);
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }

}
class student extends Person{
    public student(){

    }
    public void aa(){
        student.a("学生");
    }
}
